package route

import (
	"fmt"
	"github.com/gorilla/mux"
	"hello/app/http/middlewares"
	"hello/inits/config"
	"hello/lib/grouter"
	"hello/routes"
	"net/http"
)

func BootstrapRoute() {
	fmt.Println("路由初始化开始")
	var router *mux.Router
	router = mux.NewRouter()
	grouter.SetRoute(router)
	//GinEngine = gin.Default()
	routes.WebRoutes(router)
	routes.ApiRoutes()
	fmt.Println("Web与API路由加载完毕")
	appPort := config.GetString("APP_PORT", "9090")
	domain := config.GetString("DOMAIN", "localhost")
	fmt.Println("运行在 " + domain + ":" + appPort + "/")
	http.ListenAndServe(":"+appPort, middlewares.RemoveTrailingSlash(router))
	//err := GinEngine.Run(":" + appPort)
	//if err != nil {
	//	log.Fatal(err)
	//}
}
